{extend name="public:base" /}
{block name="theme"}权限管理{/block}
{block name="small_theme"}权限列表{/block}
{block name="content"}
<style>
    body{
        font-family: "微软雅黑";
    }
    .add-box{
        width: 100%;
        padding:10px 10px 30px 10px;
        background: #fff;
        display: flex;
        flex-flow: row wrap;
        justify-content: space-between;
    }
    .add-box>div{
        width: 49%;
        height: auto;
        border:1px solid #dfdfdf;
        padding:10px;
    }
    .box-header h2{
        color:#317eac;
        margin-top: 4px;
        margin-right: 5px;
    }
    .box-header{
        background: rgba(0,0,0,.1);
    }
    .form-group{
        width: 100%;
        display: flex;
        flex-flow: row nowrap;
        margin-bottom: 5px;
    }
    .form-group label{
        width: 15%;
        height: 30px;
        line-height: 30px;
    }
    .form-group .form-control{
        width: 85%;
        height: 30px;
        padding:3px 12px;
    }
    /*.form-group input{*/
        /*width: 85%;*/
        /*height: 30px;*/
        /*text-indent: 5px;*/
        /*outline: none;*/
        /*border:1px solid #d2d6de;*/
    /*}*/
    .form-group input:focus{
        border:1px solid #3c8dbc;
    }
    .form-group textarea{
        width: 85%;
        text-indent: 5px;
        outline: none;
        border:1px solid #d2d6de;
        resize: none;
    }
    .add-box>.btn-box{
        width: 200px;
        height: 40px;
        margin:20px auto;
        border:none;
        display: flex;
        flex-flow: row wrap;
        justify-content: space-between;
    }
    .btn-box button{
        width: 80px;
        height: 40px;
    }
    .btn-color-o{
        background: #f39c12;
        color: #fff;
    }
    .btn-color-g{
        background: #222d32;
        color: #fff;
    }
    .btn-box button:hover{
        color: #fff;
    }
</style>
    <div class="col-xs-12">
        <h3 class="header blue lighter smaller">
            <i class="ace-icon fa fa-list-alt smaller-90"></i>
            新增菜单
            <i class="ace-icon fa fa-plus smaller-90 middle" data-icon-hide="ace-icon fa fa-minus" data-icon-show="ace-icon fa fa-plus"></i>
        </h3>

        <form id="form">
            <div class="box">
                <div class="add-box">
                    <div class="box-left">
                        <div class="form-group">
                            <label>父级菜单:</label>
                            <select class="form-control" name="pid" required>
                                <option value="0">--默认顶级--</option>
                                {volist name="authrule" id="vo"}
                                    <option value="{$vo.id}" {eq name="pid" value="$vo['id']"}selected{/eq}>{$vo._name}</option>
                                {/volist}
                            </select>
                        </div>
                        <div class="form-group">
                            <label>菜单名称:</label>
                            <input type="text" name="title" required class="form-control" value="{$info.title}">
                        </div>
                        <div class="form-group">
                            <label>控制器/方法:</label>
                            <input type="text" name="name" required  class="form-control">
                        </div>
                        <div class="form-group">
                            <label>排序:</label>
                            <input type="text" name="sort" value="50"  class="form-control" >
                        </div>

                        <div class="form-group">
                            <label>样式名称：</label>
                            <input type="text" name="css" placeholder="只针对顶级栏目有效，例:fa-tachometer.." class="form-control">
                        </div>
                        <div class="form-group">
                            <label>是否显示:</label>
                            <input name="status" value="1" type="checkbox" checked/>
                        </div>
                        <div class="form-group">
                            <label>权限是否检测:</label>
                            <input name="notcheck" value="0" type="checkbox" checked/>
                        </div>

                    </div>
                    <div class="box-right">
                        <div class="form-group">
                            <label>说明：</label>
                            <input type="text" name="description" placeholder="对菜单的描述说明" class="form-control">
                        </div>
                    </div>
                    <div class="btn-box">
                        <button type="button" class="btn btn-info" id="submit">确定</button>
                        <button type="reset" class="btn btn-grey">返回</button>
                    </div>
                </div>
            </div>
        </form>
    </div>
{/block}
{block name="js"}
<script>
    $('#submit').click(function () {
        $.ajax({
            type: "POST",
            url:  "{:url('addrun')}",
            data: $('#form').serialize(),
            beforeSend:function(){
                $(this).attr("disabled","false"); //禁止点击
            },
            success: function(info){
                console.log(info);
                if(info.code==1){
                    layer.msg(info.msg, {icon: 1});
                    setTimeout(function(){
//                        location.href=info.url;
                        history.go(0);
                    },3000); //延迟演示
                }else{
                    layer.msg(info.msg, {icon: 5});
                    $('#submit').removeAttr("disabled"); //禁止点击
                }

            }
        });
        return false;
    });
    highlight_subnav("{:url('index')}");
</script>'

{/block}